package eg.edu.guc.met.agent;

import eg.edu.guc.met.engine.Cell;

public class Node implements Comparable<Node> {
	// initial state, the agent is in cell (1; 1), facing north, with a single
	// arrow, and not holding the gold.
	Cell cell;
	// for orientation 1->north 2->east 3->south 4->west
	int orientation;
	boolean arrow;
	boolean holdingGold;
	int x;
	int y;
	int cost;
	int depth;
	Node parent;
	char actionFromParent;
	int hueristic;

	public Node(Node parent, Cell cell, int orientation, boolean arrow,

	boolean holdingGold, int x, int y, int cost, int depth) {
		super();
		this.parent = parent;
		this.cell = cell;
		this.orientation = orientation;
		this.arrow = arrow;
		this.holdingGold = holdingGold;
		this.x = x;
		this.y = y;
		this.cost = cost;
		this.depth = depth;
		// actionFromParent = '.';
		if (WumpusAgent.strategies[WumpusAgent.strategyIndex].equals("ASS"))
			hueristic = getHeursitic();
		else
			hueristic = 0;
	}

	public Node() {
		// TODO Auto-generated constructor stub
	}

	private int getHeursitic() {
		return Math.abs(this.x - WumpusAgent.goldX)
				+ Math.abs(this.y - WumpusAgent.goldY);
	}

	@Override
	public int compareTo(Node o) {
		if ((this.hueristic + this.cost) < (o.hueristic + o.cost))
			return -1;
		else if ((this.hueristic + this.cost) == (o.hueristic + o.cost))
			return 0;
		else
			return 1;
	}

}